package com.pty.demo.structural.proxy;

/**
 * @author pengty
 * @date 2020/3/12
 */
public class DrinkProxy implements DrinkSubject {

    private DrinkRealSubject drinkSubject;

    @Override
    public void drink() {
        if (null == drinkSubject) {
            drinkSubject = new DrinkRealSubject();
        }
        doSthPre();
        drinkSubject.drink();
        doSthAfter();
    }

    private void doSthAfter() {
        System.out.println("do sth after, 问问水喝的怎么样");
    }

    private void doSthPre() {
        System.out.println("do sth pre, 检查你能不能喝水");
    }
}
